package com.elitesland.org.entity;


import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import com.elitesland.system.convert.BooleanToIntegerConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "org_bu")
@org.hibernate.annotations.Table(appliesTo = "org_bu", comment = "BU")
@Data
@DynamicInsert
@DynamicUpdate
@Accessors(chain = true)
@ApiModel(value = "BU", description = "BU")
public class OrgBuDO extends BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("公司ID")
    @Comment("公司ID")
    @Column()
    Long ouId;

    @ApiModelProperty("BU编号")
    @Comment("BU编号")
    @Column()
    String code;

    @ApiModelProperty("BU名称")
    @Comment("BU名称")
    @Column()
    String name;

    @ApiModelProperty("BU简称")
    @Comment("BU简称")
    @Column()
    String abbr;

    @ApiModelProperty("BU类型[UDC]ORG:BU_TYPE")
    @Comment("BU类型")
    @Column()
    String type;

    @ApiModelProperty("BU类型2")
    @Comment("BU类型2")
    @Column()
    String type2;

    @ApiModelProperty("BU类型3")
    @Comment("BU类型3")
    @Column()
    String type3;

    @ApiModelProperty("BU类型4")
    @Comment("BU类型4")
    @Column()
    String type4;

    @ApiModelProperty("BU类型5")
    @Comment("BU类型5")
    @Column()
    String type5;

    @ApiModelProperty("BU类型6")
    @Comment("BU类型6")
    @Column()
    String type6;

    @ApiModelProperty("BU类型7")
    @Comment("BU类型7")
    @Column()
    String type7;

    @ApiModelProperty(value = "是否虚拟单位，用于财务责任中心")
    @Comment("是否虚拟单位，用于财务责任中心")
    @Column()
    @Convert(converter = BooleanToIntegerConverter.class)
    Boolean isVirtual;

    @ApiModelProperty("BU状态 [UDC]COM:STATUS_BU")
    @Comment("BU状态 [UDC]COM:STATUS_BU")
    @Column()
    String status;

    @ApiModelProperty("BU状态2")
    @Comment("BU状态2")
    @Column()
    String status2;

    @ApiModelProperty("BU状态3")
    @Comment("BU状态3")
    @Column()
    String status3;

    @ApiModelProperty("上级ID")
    @Comment("上级ID")
    @Column()
    Long parentId;

    @ApiModelProperty(value = "排序号码")
    @Comment("排序号码")
    @Column()
    Integer sortNo;

    @ApiModelProperty("关系路径")
    @Comment("关系路径")
    @Column()
    String path;

    @ApiModelProperty("地址号")
    @Comment("地址号")
    @Column()
    Long addrNo;

    @ApiModelProperty("BU层级 [UDC]ORG:BU_LEVEL")
    @Comment("BU层级 [UDC]ORG:BU_LEVEL")
    @Column()
    String level;

    @ApiModelProperty("区域 [UDC]COM:REGION")
    @Comment("区域 [UDC]COM:REGION")
    @Column()
    String region;

    @ApiModelProperty("负责人员工ID")
    @Comment("负责人员工ID")
    @Column()
    Long chargeEmpId;

    @ApiModelProperty("关联BU ID-收入中心")
    @Comment("关联BU ID-事业部")
    @Column()
    Long refBuId;

    @ApiModelProperty("关联BU ID-利润中心")
    @Comment("关联BU ID-利润中心")
    @Column()
    Long refBuId2;

    @ApiModelProperty("关联BU ID-成本中心")
    @Comment("关联BU ID-成本中心")
    @Column()
    Long refBuId3;

    @ApiModelProperty("关联BU ID-费用中心")
    @Comment("关联BU ID-费用中心")
    @Column()
    Long refBuId4;

    @ApiModelProperty("关联BU ID-投资中心")
    @Comment("关联BU ID-投资中心")
    @Column()
    Long refBuId5;

    @ApiModelProperty("关联BU ID6")
    @Comment("关联BU ID6")
    @Column()
    Long refBuId6;

    @ApiModelProperty("外部编码")
    @Comment("外部编码")
    @Column()
    String externalCode;

    @ApiModelProperty(value = "岗位权重系数")
    @Comment("岗位权重系数")
    @Column()
    Double postFactor;

    @ApiModelProperty("ES1")
    @Comment("ES1")
    @Column()
    String es1;

    @ApiModelProperty("ES2")
    @Comment("ES2")
    @Column()
    String es2;

    @ApiModelProperty("ES3")
    @Comment("ES3")
    @Column()
    String es3;

    @ApiModelProperty("ES4")
    @Comment("ES4")
    @Column()
    String es4;

    @ApiModelProperty("ES5")
    @Comment("ES5")
    @Column()
    String es5;

    @ApiModelProperty("ES6")
    @Comment("ES6")
    @Column()
    String es6;

    @ApiModelProperty("ES7")
    @Comment("ES7")
    @Column()
    String es7;

    @ApiModelProperty("ES8")
    @Comment("ES8")
    @Column()
    String es8;

    @ApiModelProperty("ES9")
    @Comment("ES9")
    @Column()
    String es9;

    @ApiModelProperty("ES10")
    @Comment("ES10")
    @Column()
    String es10;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof OrgBuDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        OrgBuDO entity = (OrgBuDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}
